package config

import (
	"context"
	"github.com/gogf/gf/v2/encoding/gjson"
	"go_end/internal/dao"
	"go_end/internal/model/entity"

	"go_end/api/config/v1"
)

func (c *ControllerV1) GetConfig(ctx context.Context, req *v1.GetConfigReq) (res *v1.GetConfigRes, err error) {
	var model = new(entity.SysConfig)
	_ = dao.SysConfig.Ctx(ctx).Where("key=?", "glob_key").Scan(&model)

	res = new(v1.GetConfigRes)
	err = gjson.New(model.Value).Scan(&res)
	return res, nil
}
